﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GcmpModel.h"

#include <vector>

namespace gcmp
{
    class ElementId;
    class IElement;
}

namespace Sample
{
    //0. uid  当前用来表示具体类型时， 其来源应是pType->GetElementId().AsInt64()
    //1. name 当前用来表示具体类型时，其来源应是pType->GetBasicInformation()->GetName()
    //2. iconpath 根据实际设置
    typedef std::tuple<Int64, std::wstring, std::wstring> ElementTypeInfo;

    //0. 当前类型组信息
    //1. 当前组内包含的类型集合
    typedef std::tuple<ElementTypeInfo, std::vector<ElementTypeInfo>> ElementTypeGroup;

    //完整的属性下拉列表展示的数据源集合
    typedef std::vector<ElementTypeGroup> ElementTypeGroups;

    //为了方便外部使用属性面板中type接口的临时方案, InstanceTypePropertyPalleteBehavior从该类和PropertyPalleteBehaviorBase派生
    class ITypeGetAndSwitchBehavior
    {
        DEFINE_CAST_BASE(ITypeGetAndSwitchBehavior)
    public:

        /// \brief 获取属性面板中构件类型下拉列表的数据源
        /// 
        /// \param pDoc 当前被操作的文档指针
        /// \param pElement 当前被选中的element指针
        /// \return 可展示的Element类型数据
        virtual const ElementTypeGroups GetAllElementType(const gcmp::IDocument* pDoc, const gcmp::IElement* pElement) const = 0;

        /// \brief 将目标构件切换至当前Behavior所属的Owner类型
        ///
        /// \param pElement 待切换类型的目标构件
        /// \return bool 是否切换成功
        virtual bool SwitchTypeOfElement(gcmp::IElement* pTypeToBeSwitchedElement) = 0;
    };
}

